package com.mdnote.jianzhi_offer.recursion;

/**
 * @author Rhythm-2019
 * @version 1.0
 * @date 2020/10/12 0012
 * @description 斐波那契数列
 */
public class Offer10I {

    public int fib(int n) {

        if (n < 2) {
            return n;
        }
        // base case
        int r = 0, j = 1, k = 0;
        for (int i = 2; i < n + 1; i++) {
            k = (r + j) % 1000000007;
            r = j;
            j = k;
        }
        return k;
    }
}
